package toanstt.com.menu;

import toanstt.com.MatchUp.App;
import toanstt.com.MatchUp.ButtonCenter;
import toanstt.com.MatchUp.MainActivity;
import toanstt.com.MatchUp.SCR;
import toanstt.com.MatchUp.Sound2;
import toanstt.com.MatchUp.T;
import toanstt.com.gameplay.G;
import toanstt.com.gameplay.GameStatus;
import android.graphics.Canvas;
import android.view.MotionEvent;

public class Thumbs 
{
	ButtonCenter[] buttons;
	ButtonCenter back;
	int thumb_index = 0;
	public Thumbs()
	{
		
		if(T.ISHORIZONTAL)
		{
			{
				int i,j;
				int dx =  (int)(T.TBITMAP_THUMBS.bitmap[0].getWidth()*1.25);
				int dy =  (int)(T.TBITMAP_THUMBS.bitmap[0].getWidth()*1.1);
				int minx = T.DISPLAY_WIDTH/2 - (int)(T.TBITMAP_THUMBS.bitmap[0].getWidth()*1.875);
				int miny = (int)(dx/1.5);
				buttons = new ButtonCenter[24];
				for(i =0;i<6;i++)
					for(j =0;j<4;j++)
					{
						buttons[i*4+j] = new ButtonCenter(T.TBITMAP_THUMBS.bitmap[0],minx + j*dx,miny+i*dy);
					}
				back = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[13],T.DISPLAY_WIDTH/2,(int)(T.DISPLAY_HEIGHT - 50- (int)(2*T.U2)));
			}
		}

	}
	int d;
	public void Draw(Canvas canvas)
	{ 
		
		{
			
			canvas.drawBitmap(T.TBITMAP_THEME_WHITE.bitmap[0], 0, 0, null);
			back.Draw2(canvas);
			for(d =0;d<24;d++)
			{
				T.Show("AAAAAAAAAAAA  " + T.PLAYER_I1 + " " + T.PLAYER_I2 );
				if(thumb_index > T.PLAYER_I1 || d > T.PLAYER_I2 )
					buttons[d].bitmap = T.TBITMAP_THUMBS.bitmap[4];
				else
				//if(T.GAME_DATA[thumb_index][d]>0)
					buttons[d].bitmap = T.TBITMAP_THUMBS.bitmap[T.GAME_DATA[thumb_index][d]];
				//[][];
				buttons[d].Draw2(canvas);
			}
		}
		
	}
	int t;
	public void touch(MotionEvent mo)
	{
		if(back.Kick(mo) == true)
		{
			T.sounds.Play(Sound2.BUTTON_CLICK);
			//T.SCREEN = SCR.NEWGAME;
			if(T.SCREEN_TEMP == -1)
			{
				T.SCREEN_TEMP = SCR.NEWGAME;
				T.ALPHA =T.ALPHA_COUNT_MAX;
			}
		}
		else
		{
		for(t =0;t<24;t++)
		{
			
			if(buttons[t].Kick(mo))
			{
				if(t > T.PLAYER_I2)
				{
					T.TOAST("Cannot play locked level!");
					break;
				}
				if(T.SCREEN_TEMP == -1)
				{
					T.sounds.Play(Sound2.BUTTON_CLICK);
					T.GAME_I1 = thumb_index;
					T.GAME_I2 = t;
					T.ALPHA =T.ALPHA_COUNT_MAX;
					T.GAMEPLAYMODE =2;
				}
				
				//G.NewGame(thumb_index,t);
					
				App.ads.setTurnON();
				break;
			}
		}}
		 
		
		switch(App.action)
		{
			case MotionEvent.ACTION_DOWN:
				
			break;
			
			case MotionEvent.ACTION_UP:
				for(t =0;t<24;t++)
					buttons[t].anpla = 255;
				back.anpla = 255;
			break;
			
			case MotionEvent.ACTION_MOVE:
			break;

		}
	}
}
